package com.aoyy.controller;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.aoyy.service.ForumService;
import com.aoyy.util.Page;
import com.aoyy.constant.Constants;
/**=======================================================================================================
 * Forum controller <code>ForumController</code> for index page is to display all boards. 
 * @author this author
 * @date 2017-08-14
 * =======================================================================================================
 */
@Controller
public class ForumController extends BaseController {
	@Autowired
	private ForumService forumService;
	
	@RequestMapping(value="/index", method={RequestMethod.GET}) 
	public String toIndex(HttpServletRequest request, @RequestParam(value="pageNo", required=false) Integer pageNo, Map<String, Object> map) {
		pageNo = (pageNo == null) ? 1 : pageNo;
		Page pagedBoards = forumService.pagedQuery(pageNo, Constants.PAGE_SIZE); 
		map.put("pagedBoards", pagedBoards);
		this.setSessionBoardPathURl(request, "/index");
		return "index";
	}

}
